package com.qdu.dao;

import com.qdu.entity.ActiCommentReply;
import com.qdu.util.DatabaseUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 *根据活动评论（acommentId）的id，返回回复的一个列表
 * @author 19645
 */
public class ActiCommentReplyDao {
    public List<ActiCommentReply> getACommentReplyByCommentAndUserId(String acommentId) {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        List<ActiCommentReply> list = new ArrayList<>();
        
        try {
            con = DatabaseUtil.getConnection();
            //获得用户名称，内容，回复时间，点赞数
            ps = con.prepareStatement("select Uid,ACRcontent,ACRtime,ACragree from Activity where ACid=?");
            ps.setString(1, acommentId);
            rs = ps.executeQuery();
            while (rs.next()) {
                list.add(new ActiCommentReply
                            (   rs.getString(1),
                                rs.getString(2), 
                                rs.getString(3), 
                                rs.getInt(4)
                            )
                );
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DatabaseUtil.close(rs, ps, con);
        }
        return list;
        
    }
    
}
